package com.news.util;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisUtil {

	private static JedisPool jedisPool;

	static{
		JedisPoolConfig config = new JedisPoolConfig();
		//设置最大连接数
		config.setMaxTotal(20);
		//设置连接的最大时长
		config.setMaxWaitMillis(10000);
		
		jedisPool = new JedisPool(config,"192.168.196.130",10012);
	}
	
	public static Jedis getJedis(){
		
		Jedis jedis = jedisPool.getResource();
		
		return jedis;
	}
	public static void closeJedis(Jedis jedis){
		
		jedis.close();
	}
}
